#coding=utf-8

require "aio/core"

class Aio::Module::Cmd::Maipu::ShowClock < Aio::Module::Cmd::Maipu
  include Aio::Module

  def initialize
    super({
      :cmd_full     => "show clock",
      :cmd_short    => "sh clo",
      :author       => "Elin",
      :description  => "This is Maipu Command# show clock",
      :ranking      => Ranking_1,
      :platform     => "all"
    })
  end

  def parse
    context = self.context.dup
    clock = {}
    useful[:clock] = clock
    context.readline_match_block(/(?<zone>.*)\.\d+ (?<week>[^\s]+) (?<month>[^\s]+) (?<day>[^\s]+) (?<time>[^\s]+) (?<year>[^\s]+)/) do |block|
      block.update(clock, :time)
      block.update(clock, :zone)
      block.update(clock, :week)
      block.update(clock, :year)
      block.update(clock, :month, Aio::Base::Toolkit::Date.month_to_i(block[:month]))
      block.update(clock, :day)
    end
  end
end
